//
//  HomePViewController.m
//  HunBa.
//
//  Created by 维Sir on 16/5/30.
//  Copyright © 2016年 fubang. All rights reserved.
//

#import "HomePageViewController.h"
#import "SegmentView.h"
#import "OneTableViewCell.h"
#import "TwoTableViewCell.h"
#import "LBTableViewCell.h"
#import "InfiniteScrollPicker.h"
#import "ILSideScrollView.h"
#import "ILSideScrollViewItem.h"
@interface HomePageViewController (){
    InfiniteScrollPicker *isp3;

}
@property (nonatomic,strong)  SegmentView *segmentedControl;

@end

@implementation HomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self bar];
    [self setSegmentControl];
//    [self C];
    // Do any additional setup after loading the view from its nib.
}
//-(void)C{
//
//     _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, 10, 10, 10)];
//    [self.tableview addSubview:_collectionView];
//    
//
//}
-(void)bar{
    [self.navigationController.navigationBar setBarTintColor: [UIColor colorWithRed:244/255.0 green:169/255.0 blue:39/255.0 alpha:1]];
}
-(void)SC{
  
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else if(section == 1) {
        return 1;
    }else{
        return 5;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.section == 0) {
        return 302;
    }else if(indexPath.section == 1) {
        return 120;
    }else{
        return 100;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    //    NSDictionary * DIC = [_dataSource objectAtIndex:indexPath.row];
    if (indexPath.section == 0) {
        OneTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OneTableViewCell"];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"OneTableViewCell" owner:self options:nil] lastObject];
            NSMutableArray *set3 = [[NSMutableArray alloc] init];
            for (int i = 0; i < 6; i++) {
                [set3 addObject:[UIImage imageNamed:[NSString stringWithFormat:@"%d-.png", i]]];
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
            }
            isp3 = [[InfiniteScrollPicker alloc] initWithFrame:CGRectMake(0, 10, 385, 240)];
            [isp3 setImageAry:set3];
            [isp3 setHeightOffset:20];
            [isp3 setPositionRatio:2];
            [isp3 setAlphaOfobjs:0.8];
            [cell.contentView addSubview:isp3];
        }
        return cell;
    }if (indexPath.section == 1){
        TwoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TwoTableViewCell"];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"TwoTableViewCell" owner:self options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            NSMutableArray *items = [[NSMutableArray array] init];
            
            for (int i = 0; i <= 6; i++) {
                ILSideScrollViewItem *item = [ILSideScrollViewItem item];
                
                item.backgroundColor = [UIColor colorWithPatternImage:
                                        [UIImage imageNamed:@"image.png"]];
                item.defaultTitleColor = [UIColor brownColor];
                item.selectedTitleColor = [UIColor redColor];
                
                [item setTarget:self action:@selector(showAlertForItem:) withObject:item];
                [items addObject:item];
            }
            CGFloat originY = scroller2.frame.origin.y+scroller2.frame.size.height;
            scroller3 = [[ILSideScrollView alloc] initWithFrame:
                         CGRectMake(0,0,375,100)];
            [scroller3 setBackgroundColor:[UIColor whiteColor]
                           indicatorStyle:UIScrollViewIndicatorStyleWhite
                          itemBorderColor:[UIColor blackColor]];
            [scroller3 populateSideScrollViewWithItems:items];
            [cell.contentView addSubview:scroller3];
        }
        return cell;
    }if (indexPath.section == 2) {
        LBTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LBTableViewCell"];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"LBTableViewCell" owner:self options:nil] lastObject];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }
        return cell;
    }
    return nil;
}
-(void)setSegmentControl{
    _segmentedControl = [[SegmentView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 98) titles:@[@"推荐",@"分类",@"榜单",@"DJ"] images:nil selectImages:nil clickBlick:^(NSInteger index) {
        // 存储点击第几个
    }];
    [self.view addSubview:self.segmentedControl];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
